Skip to content

feat: support configurable lanes in agent queue APIs#431

Merged
joryirving merged 2 commits into
mainfrom
feat/configurable-agent-queue-lanes
Jun 17, 2026
Merged

feat: support configurable lanes in agent queue APIs#431
joryirving merged 2 commits into
mainfrom
feat/configurable-agent-queue-lanes

Conversation

@joryirving

Copy link
Copy Markdown
Contributor

Closes #384

Validate the lane query parameter against configured lanes at runtime
instead of hardcoding normal/escalated/backlog allowlists. Unknown
lanes now return a clear 400 error with available lane ids.

- Add lane validation to GET /api/agents/{name}/queue
- Add lane validation to GET /api/agents/{name}/next-task
- Preserve all existing query params: exclude_decomposed, includeClaimed,
  includeRenovate
- Backward-compatible: omitting lane still works
- Custom configured lanes can be queried successfully
- Non-claimable lanes excluded from default worker queue
- Response includes issue lane value
its-saffron[bot]

This comment was marked as outdated.

@its-saffron its-saffron Bot dismissed their stale review June 17, 2026 20:13

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@joryirving joryirving added the ai-review Request an AI pull request review. label Jun 17, 2026
@its-saffron its-saffron Bot dismissed their stale review June 17, 2026 20:16

Superseded by a newer automated review for this pull request.

@its-saffron its-saffron Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Automated Review

Full PR review.

Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic) — routed smart (risk match: public_route_changes)

PR Review: feat: support configurable lanes in agent queue APIs

Recommendation: Approve

This PR implements configurable lanes for the agent queue APIs, adding lane validation and authorization controls. The implementation is well-tested and follows repository conventions.


Change-by-Change Findings

1. src/app/api/agents/[agentName]/queue/route.ts (+17 lines)

  • Added authorization check: The /queue endpoint now requires bearer token authentication via authorizeRequest(). Requests without valid tokens receive 401 Unauthorized.
  • Added lane validation: When a lane query param is provided, it is validated against configured lanes using isValidLane(). Invalid lanes return 400 with a descriptive error message including valid options.
  • Backward compatibility: Omitting the lane param preserves existing default behavior.

2. src/app/api/agents/[agentName]/next-task/route.ts (+11, -1 lines)

  • Added lane validation: Same validation pattern as queue endpoint — checks isValidLane() when lane is provided, returns 400 for unknown lanes.
  • Existing auth intact: The endpoint already had authorizeRequest() check (confirmed via file read).

3. src/app/api/agents/[agentName]/queue/route.test.ts (+365 lines)

  • Comprehensive test coverage added for:
    • Auth: 401 for missing/invalid tokens, proper behavior with valid tokens
    • Auth isolation: unauthorized requests don't trigger DB queries
    • Lane validation: 400 for unknown lanes, 200 for valid lanes
    • Backward compatibility: omitting lane param works
    • Custom lanes: tests with fast/slow/parked and alpha lane configs
    • Lane filter interactions: includeClaimed, includeRenovate, exclude_decomposed preserved
    • Response includes lane value as required

4. src/lib/agent-queue.test.ts (+117 lines)

  • Tests for configurable lane scenarios:
    • Single claimable lane config
    • Three claimable lanes config
    • Non-claimable lanes excluded by default
    • Non-claimable lanes can be included with claimableOnly: false

Required Checks

✅ verify route access controls are in place

Both /api/agents/{agentName}/queue and /api/agents/{agentName}/next-task endpoints now require bearer token authorization via authorizeRequest(). The queue endpoint received explicit auth protection in this PR. Tests confirm:

  • 401 returned when no auth header present
  • 401 returned for invalid bearer token
  • Valid bearer token allows access
  • Unauthorized requests do not invoke database queries

✅ check for unintended public endpoints

No unintended public endpoints introduced. Both modified routes (/queue and /next-task) are internal agent API endpoints requiring bearer token authentication. No authentication was removed; the queue endpoint was strengthened with explicit auth checks.


Standards Compliance

  • API routes return appropriate status codes: 401 for unauthorized, 400 for invalid lane, 200 for success. ✅
  • Error handling uses error instanceof Error pattern: Error responses are structured JSON objects. ✅
  • Bearer token auth: Uses DISPATCH_AGENT_TOKEN per repository conventions. ✅
  • No secrets committed: No .env files or credentials in diff. ✅
  • Test conventions: Tests mock dependencies, use beforeEach/afterEach cleanup, and test both positive and negative cases. ✅

Linked Issue Fit

Issue PR 384 acceptance criteria are satisfied:

Criteria Status
Default normal queue behavior still works ✅ Tested
Default escalated queue behavior still works ✅ Tested
Custom configured lane can be queried successfully ✅ Tested
Unknown lane query returns clear error ✅ Returns 400 with valid options
Single claimable lane config works ✅ Tested
Three claimable lane config works ✅ Tested
Non-claimable lanes excluded from worker queues ✅ Tested
Tests cover default and custom lanes ✅ Comprehensive

Evidence Provider Findings

No evidence providers were configured for this PR. No blockers identified.


Tool Harness Findings

No additional verification needed — the files were read directly and confirm:

  • Both endpoints have authorizeRequest() checks
  • Lane validation uses isValidLane() and getLaneIds() from @/lib/lane-config
  • Error responses are structured consistently

Unknowns / Needs Verification

None. The implementation is fully verified from the diff and test coverage.


Conclusion

This PR adds configurable lane support to agent queue APIs while maintaining backward compatibility and adding proper authorization controls. The implementation is well-tested and meets all acceptance criteria from issue PR 384. CI passed (Validate, review, Docker Build all succeeded).

@its-saffron its-saffron Bot removed the ai-review Request an AI pull request review. label Jun 17, 2026
@joryirving joryirving merged commit cc34ef7 into main Jun 17, 2026
4 checks passed
@joryirving joryirving deleted the feat/configurable-agent-queue-lanes branch June 17, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: support configurable lanes in agent queue APIs

1 participant